(function(){
    var factory = {
        init: function(){
            var _this = this;

            _this.selector = $('#m-check');

            _this.handle();
        },
        handle: function(){
            var _this = this;

            _this.selector.delegate('.checkbox-self', 'click', function(e){
                if($(this).hasClass('unchecked')) {
                    $(this).removeClass('unchecked').addClass('checked');
                }else{
                    $(this).removeClass('checked').addClass('unchecked');
                }
            });

            //查看全部
            _this.selector.delegate('.show-more', 'click', function(e){
                $(this).parent('.short-remarks').hide().next('.total-remarks').show();
            });
            //收起
            _this.selector.delegate('.hide-more', 'click', function(e){
                $(this).parent('.total-remarks').hide().prev('.short-remarks').show();
            });

            //下单
            _this.selector.delegate('.u-mk-order', 'click', function(){
                var id = $(this).parents('.list').data('id');
                var serviceids = '';
                $(this).parents('.list').find('.checked').each(function(){
                    serviceids += $(this).data('uid') + ',';
                });
                serviceids = serviceids.slice(0, -1);

                window.location.href = '/orders' + '?id=' + id + '&serviceids=' + serviceids + "&relate=product_list";
            });
        }
    };

    module.exports = factory;
})();